home *** CD-ROM | disk | FTP | other *** search
- /*
- * Textfiles Module - Version 1.0 - By Scott Szretter
- *
- * (C)1991 Scott Szretter - Please see the file "COPYRITE.SPS"
- *
- * ))) Version Changes (((
- * --Version-------------Notes-----------------------------------------------------------------
- * 1.0 -> 1.0 ... Name change (gfiles -> textfiles) & ease of use for user upgrade.
- *
- * This program may not be sold for profit!
- * The source code is being release for educational purposes only.
- * I take no responsibility for any damage resulting from this code.
- */
- #define INMAIN
- #include <SetUpA4.h>
- #include "MUBBS Module.h"
- pascal void main (mode1,G1,P1)
- short mode1;
- struct GS *G1;
- Ptr *P1;{
- Handle temph;
- float version = 0.5; /* version of MUBBS */
- RememberA0(); SetUpA4();
- asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* lock our module. */
- G=G1;
- mode[u]=mode1;
-
- switch (mode[u]) {
- case 2:
- Textfiles();
- G->moduleresult=0;
- break;
- case 98:
- versionck(version);
- break;
- case 0:
- strcpy (G->programmer,"Scott Szretter");
- G->moduleresult=0;
- break;
- default:
- G->moduleresult=1;
- break;};
- HUnlock(temph); /* unlock module.*/
- RestoreA4();}
-
- /**** * * * -Textfiles- * * * * ****/
- Textfiles() {
- FILE *stream;
- char tempstring[100];
- char m_realnames[12][41];
- char modulesc[12][10];
- short i,a,f;
- short itemp;
-
- if (!G->online[u]) return;
- loguser(G->modulename[u]);
- print("C> Line %d %s, at: %s\n",(u+1),G->username[u],G->modulename[u]);
-
- strcpy(tempstring,":textfiles:");
- strcat(tempstring,G->modulename[u]);
- strcat(tempstring,".intro");
- sendtext(tempstring);
-
-
- strcpy(tempstring,":textfiles:");
- strcat(tempstring,G->modulename[u]);
- strcat(tempstring,".info");
-
- i = 0;
- /* Open the file */
- if ((stream = fopen(tempstring, "r")) == NULL) {
- send("]FILE ERROR cannot open %s ", /*its a %d ,errno,*/ tempstring);
- print("]FILE ERROR!!!! cannot open %s ",tempstring);
- return;
- }
- else /* If no error, read from the file */
- {
- a = 0;
- while (a == 0){
- if(fgets(modulesc[i],5,stream) != NULL) { /* Read and check for EOF */
- if (fgets(m_realnames[i],39,stream) != NULL) { /* Read and check for EOF */
- remlf(m_realnames[i]); /* take out line feed */
- remlf(modulesc[i]);
- i++;
- if (i >= 9) a = 1;
- }
- }
- else {
- a = 1;
- }
- }
- fclose(stream);
- if (!G->online[u]) return;
- }
-
- /* Display list of text files - first coming into module */
-
- f = 0;
- a = 0;
- while (a == 0){
- itemp=strtoint(modulesc[f]);
- if(G->userpriv[u] >= itemp){
- send("]");
- send("(");
- inttostr(f,tempstring);
- send(tempstring);
- send(") ");
- send(m_realnames[f]);} /* userpriv >= itemp */
- f++;
- if (f >= i) a = 1;
- } /* while a==0 */
- f=0;
- Mainpart:
- if (!G->online[u]) return;
- if (!(cmd1("]]Type File Number To Display -Or- ] >> Help, Files, Quit:"))) G->online[u]=FALSE;
- send(G->CR[u]);
- if (G->input[u] =='Q') { /* user quits */
- print("C> Exiting Textfiles -> ",G->username[u]);
- return;} /* input = Q */
- if (G->input[u] =='H') { /* user wants help */
- strcpy(tempstring,":textfiles:");
- strcat(tempstring,G->modulename[u]);
- strcat(tempstring,".help");
- send (G->CR[u]);
- sendtext(tempstring);
- send ("]]Textfiles Module 1.0 By - Scott Szretter");
- goto Mainpart;
- } /* input = H */
- if (G->input[u] =='F'){ /* user wants list of files */
- f = 0;
- a = 0;
- while (a == 0){
- itemp=strtoint(modulesc[f]);
- if(G->userpriv[u] >= itemp){
- send("]");
- send("(");
- inttostr(f,tempstring);
- send(tempstring);
- send(") ");
- send(m_realnames[f]);}
- f++;
- if (f >= i) a = 1;
- } /* while a==0 */
- f=0;
- goto Mainpart;
- } /* input = F */
- if (G->input[u] =='Z'){
-
- send(modulesc[f]);
- send("]");
- send(m_realnames[f]);
- goto Mainpart;
-
- } /* end Z */
- strcpy(tempstring,&G->input[u]);
- f=strtoint(tempstring);
- if (f > i-1) {
- send("]Invalid selection (#,H,Q,or F) please...]");
- goto Mainpart;}
- if (f < 0) {
- send("]Invalid selection (#,H,Q,or F) please...]");
- goto Mainpart;}
- send("]]");
- strcpy(tempstring,":textfiles:");
- itemp=strtoint(modulesc[f]);
- if(G->userpriv[u] >= itemp) {
- strcat(tempstring,m_realnames[f]);
- sendtext(tempstring); }
- else
- send("]]Sorry, you do not have access to that file...");
-
- goto Mainpart;
- } /* Textfiles() */
-
- remlf(string)
- char *string;
- {
- short temp,b;
- b = strlen(string);
- for (temp=0; temp<= b; temp++)
- {
- if (string[temp] == 10)
- string[temp] = 0;
- }
-
- }
-